package com.shopping.mall.auth.VO;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.constraints.*;
import javax.validation.groups.Default;

/**
 * @Author ZZY
 * @Date 2021/7/27
 */
@Data
public class UserVo {

    public interface register extends Default {
    }

    public interface login extends Default {
    }

    public interface changePassword extends Default {
    }

    public interface changeUserInfo extends Default {
    }

    public interface resetPassword extends Default {
    }

    public interface changeUserInfoByAdmin extends Default {
    }

    @NotBlank(groups = changeUserInfoByAdmin.class)
    private String id;

    private String username;

    @NotBlank(groups = {register.class, login.class, changePassword.class}, message = "密码不能为空")
    @Pattern(regexp = "(?!.*\\s)(?!^[\\u4e00-\\u9fa5]+$)(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{8,16}$", message = "8-16个字符,不包含空格,必须包含数字,字母或字符至少两种")
    @Null(groups = {changeUserInfo.class}, message = "不能提交密码")
    private String password;

    @NotBlank(groups = {changePassword.class, resetPassword.class}, message = "修改的密码不能为空")
    @Pattern(groups = {changePassword.class, resetPassword.class}, regexp = "(?!.*\\s)(?!^[\\u4e00-\\u9fa5]+$)(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{8,16}$", message = "8-16个字符,不包含空格,必须包含数字,字母或字符至少两种")
    private String changedPassword;//修改后密码

    @ApiModelProperty(value = "姓")
    private String familyName;

    @Email
    @NotBlank(groups = {register.class, login.class, changePassword.class}, message = "邮箱不能为空")
    @Null(groups = {changeUserInfo.class, changeUserInfoByAdmin.class}, message = "不能修改邮箱")
    private String mail;

    @Null(groups = {changeUserInfo.class, changeUserInfoByAdmin.class}, message = "不能修改角色")
    private Integer role;

    //    @Null(groups = {changeUserInfo.class}, message = "不能修改手机")
//    @Pattern(regexp = "^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\\d{8}$")
    private String phone;

    private Integer age;

    private Integer gender;

    private String place;

    private String languageId;

    @NotBlank(groups = {resetPassword.class}, message = "验证码不能为空")
    @Length(groups = {resetPassword.class}, min = 6, max = 6, message = "验证码必须为6位")
    private String code;
}
